<?php 
	if(isset($message)){
		echo $message;
	} else {
?>
<h1>Biometric</h1>
<?php if(isset($bio)){?>
<table cellpadding="5" cellspacing="5">
	<tr>
		<td>Filename:</td>
		<td><b><?php echo $bio->file_name;?></b></td>
	</tr>
	<tr>
		<td>Orig Filename:</td>
		<td><b><?php echo $bio->orig_file_name;?></b></td>
	</tr>
	<tr>
		<td>Size:</td>
		<td><b><?php echo $bio->file_size;?> Mb</b></td>
	</tr>
	<tr>
		<td>Date Uploaded:</td>
		<td><b><?php echo DateUtils::formatDate($bio->date_created, DateUtils::$FRIENDLY_DATE_FORMAT)?></b></td>
	</tr>
	<tr>
		<td>Uploaded By:</td>
		<td><b><?php echo StringUtils::concat(array($bio->first_name, $bio->middle_name, $bio->last_name)); ?></b></td>
	</tr>
	<tr>
		<td>Loaded?:</td>
		<td><b><?php echo $bio->is_loaded?'Yes':'No'?></b><td>
	</tr>

	<tr>
		<td colspan="2">
		<?php if($bio->is_loaded){?>
		<input type="button" name="submit" value="Close" onClick="parent.$.fancybox.close();">
		<?php } else { ?>
		<input type="button" name="submit" id="submit_button" value="Load Biometric File">
		<?php } ?>
		</td>
	</tr>
	
</table>
<?php } ?>
<?php } ?>
<p id="preloader"><img src="/images/common/ajax-loader-green.gif" align="absmiddle"> Loading biometric file to the database, please wait...<p>


<script language="javascript">
$(document).ready(function(){
	var loaded = false;
	$('p#preloader').hide();
	$('input#submit_button').click(function(){
		if(loaded != false) return;
		loaded = true;
		$('p#preloader').show();
		var url = '<?php echo base_url()?>biometric/load/' + '<?php echo $bio->id?>';
		$.get(url, function(data) {
			//alert(data);
			if(data == 'success') {
				alert('Biometric file was successfully loaded to your database.');
			} else {
				alert('Sorry, there was a problem loading the biometric file. Please reload it.');
			}
			
			parent.$.fancybox.close();
		});
		
	})
})

</script>
